﻿<%@ Page Language="C#" enableEventValidation="false" validateRequest="false"  AutoEventWireup="true" CodeBehind="notify_manage_edit.aspx.cs" Inherits="Ccit.OA.Notify.notify_manage_edit" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
<%@ Register TagPrefix="ccit" TagName="attach" Src="../UserControls/AttachUpLoad.ascx" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>通知管理-通知发布</title>
    <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
    <script type="text/javascript">
                function doSelUser(vRagneId,vCtrlId,vCtrlName) {
                OpenRangeSelect(vRagneId,vCtrlId,vCtrlName,"1");
          }
            function CheckForm()
            {
                var vtitle = document.getElementById("txtName").value;
                var vtype = document.getElementById("ddlType").value;
                var rangemark=document.getElementById("_hidRangeMarkId").value;
                var range=document.getElementById("_hidRange").value;
                var vcontent=document.getElementById("freText").value;
                if(vtitle.Trim()=="")
                {
                    alert("通知标题不能为空!")
                    return false;
                }
                if(vtype=="")
                {
                    alert("通知类型不能为空!")
                    return false;
                }
                if(rangemark==""||range=="")
                {
                    alert("通知范围不能为空!")
                    return false;
                }
                if(vcontent=="")
                {
                    alert("通知内容不能为空!")
                    return false;
                }
                return true;
            }
            function doSave(vstate,vtype)
            {
                if(!CheckForm())return;
                var vtitle = document.getElementById("txtName").value;
                var vtypeValue = document.getElementById("ddlType").value;
                var vdeptId = document.getElementById("ddlDeptId").value;
                var rangemark=document.getElementById("_hidRangeMarkId").value;
                var range=document.getElementById("_hidRange").value;
                var vcontent=document.getElementById("freText").value;
                var MsNotify = {};
                MsNotify.id = document.getElementById("_hidsRecId").value;
                MsNotify.title = vtitle;
                MsNotify.type = vtypeValue;
                MsNotify.deptid = vdeptId;
                MsNotify.content = vcontent;  
                MsNotify.importance = document.getElementById("ddlImportance").value;     
                MsNotify.rangemark = rangemark;                          
                MsNotify.range = range;
                MsNotify.state = vstate; 
                var Vreceipt = document.getElementById("chkOpinion");
                if(Vreceipt.checked==true)
                 {
                    MsNotify.receipt="1";
                    MsNotify.receiptcontent = document.getElementById("txtRcontent").value;    
                 }
                 else
                 {
                    MsNotify.receipt="0";
                 }
                   var jsonExpr = JSON.stringify(MsNotify,function(key,value){return value;}); 
                      MsNotify = null;
                    PageMethods.DoSave(jsonExpr,vtype,ClientBack); 
            }
          function ClientBack(vResult)
          {
                eval("resultObj ="+vResult)
                if(resultObj.result!="-999")
                {
                    if(resultObj.resulttype!="3")
                    {
                        alert(resultObj.message);                   
                    }
                    switch(resultObj.resulttype){
                         case "1":
                            $get("_hidsRecId").value = resultObj.resultSign;  
                             __doPostBack("lnbQuery",""); 
                            break;
                         case "2":   
                            $get("_hidsRecId").value = resultObj.resultSign;  
                            __doPostBack("lnbQuery",""); 
                            DoBack();
                            break;  
                         case "3":
                               var FileId = resultObj.resultSign; 
                               var oPageParam="RemindID=-1&FileId="+FileId;
                               var oEncodeParam=base64encode(oPageParam);   
                               var strUrl = "../WorkRemind/WorkRemind_fileSet_Set.aspx?"+oEncodeParam; 
                               OpenWindow(strUrl,"","800","450");
                    }                     
                }
                else
                {
                    alert(resultObj.message)
                }
                resultObj = null;
            }
            function doRemind()
            {
                var vsRecId= document.getElementById("_hidsRecId").value; 
                if(vsRecId=="")
                {
                    doSave("1","3");
                }
                else
                {                      
                   var oPageParam="RemindID=-1&FileId="+vsRecId;
                   var oEncodeParam=base64encode(oPageParam);   
                   var strUrl = "../WorkRemind/WorkRemind_fileSet_Set.aspx?"+oEncodeParam; 
                   OpenWindow(strUrl,"","800","450");
                }
            }
            function DoBack()
            {
                var strUrl = "notify_manage_list.aspx";
                window.location.href = strUrl;
            }
            function doCheckOption()
            {
                var Vreceipt = document.getElementById("chkOpinion");
                if(Vreceipt.checked==true)
                 {
                    document.getElementById("txtRcontent").disabled ="";
                 }
                else{
                    document.getElementById("txtRcontent").disabled ="disabled";
                }
            }
            function DoSearch()
            {
                 var vtype = document.getElementById("ddlType").value;
                 if(vtype!="")
                 {
                     PageMethods.GetContent(vtype,ClientCallBack); 
                 }
            }
            ///给文本编辑器赋值
            function ClientCallBack(vResult)
            {
               if(vResult!="")
               {
                 var sContent;
                 if(document.getElementById("freText").value!="")
                 {   
                   sContent = "<br>" + vResult; 
                 }
                 else
                 {sContent = vResult;}
                 if (freText_HtmlMode) 
                    {
		                freText_editor.document.body.innerText +=sContent ;
		                $get("freText").value = freText_editor.document.body.innerText ;
	                } 
	                else 
	                {
		                freText_editor.document.body.innerHTML += sContent;  
		                $get("freText").value =freText_editor.document.body.innerHTML ;
	                }
	                if ($get("freText").value == '<P>&nbsp;</P>') {
		                $get("freText").value = '';
	                } 
	           }
            }     
        /* UpLoad File */
            function doUploadFile()
            {
                OpenUpLoadPage();
            } 
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <asp:LinkButton ID="lnbQuery" CssClass="linktext" runat="server" 
        onclick="lnbQuery_Click"></asp:LinkButton>
     <input type="hidden" id="_hidsRecId" runat="server" />
      <input type="hidden" id="_hidType" runat="server" />
    <table class="tbToolbar" cellpadding="0" cellspacing="0" width="98%" align="center" id="TablePrint">
                <tr>
                    <td align="left">
                        <div class="tbSeparator"></div>
                    </td>
                    <td width="100%" class="titlebar">  
                        通知管理-通知发布
                    </td>                
                    <td align="right">
                        <nobr>  
                        </nobr>
                    </td> 
                </tr>
      </table>
       <table cellpadding="0" class="tableborder" cellspacing="0" width="98%" align="center" id="tdMessage" runat="server">
            <tr>
			  <td  width="15%" align="right" class="pformleft"><nobr>通知标题</nobr>			  </td>
			    <td  align="left" class="pformrightline" >
				    <asp:TextBox  ID="txtName" Runat="server" CssClass="input" Width="98%"></asp:TextBox>	
				</td>
				<td   align="right" class="pformleft"><nobr>重要程度</nobr>			  </td>
			    <td  align="left" class="pformright" >
				    <asp:DropDownList  ID="ddlImportance" Runat="server" CssClass="input" Width="90%"></asp:DropDownList>	
				</td>
			</tr> 
			<tr>
			    <td  width="15%"  align="right" class="pformleft"><nobr>通知类型</nobr>			  </td>
			    <td  align="left" class="pformrightline">
			        <nobr>
				     <asp:DropDownList  ID="ddlType" Runat="server" CssClass="inputselect" Width="120"></asp:DropDownList>
				       <a  id="lndSearch" Runat="server" class="linktext"  
                            href="javascript:DoSearch()"><img src="../images/toolbar/search.gif" border="0">应用模板</a> 
				    </nobr>	
				</td>
			    <td  width="15%" align="right" class="pformleft"><nobr>发布部门</nobr>			  </td>
			    <td  align="left" class="pformright">
			        <nobr>
				        <asp:DropDownList ID="ddlDeptId" runat="server" Width="120" CssClass="inputselect"></asp:DropDownList>
				    </nobr>	
				</td>
			</tr> 
			<tr>
			     <td  width="15%"  align="right" class="pformleft"><nobr>通知范围 
			      <br />
                        <a href="javascript:doSelUser('_hidRangeMarkId','_hidRange','txtRange')">
                            <img src="../images/toolbar/search.gif" border="0" /></a>   
			     </nobr>			  </td>
			     <td  align="left" class="pformrightline" colspan="3">
			         <nobr>
                        <input type="hidden" id="_hidRangeMarkId" runat="server" />
                        <input type="hidden" id="_hidRange" runat="server" />
                        <asp:TextBox ID="txtRange" TextMode="MultiLine" Width="98%" 
                        Height="70px" runat="server" ReadOnly="true" CssClass="inputtext"></asp:TextBox>
				    </nobr>		
				</td>
			</tr>
			<tr>
				<td class="pformleft" align="right">附件列表
				</td>
				 <td align="left" class="pformrightline"  colspan="3">
                     <a href="javascript:doUploadFile()" runat="server" class="linktext" id="afile">上传附件</a>
                 </td>
			</tr>
			 <tr> 
                    <td align="center"  class="pformleft"> 
                        &nbsp;</td>
                     <td align="left" class="pformrightline"  colspan="3">
                          <ccit:attach id="ucAttach" ShowStyle="1" runat="server"></ccit:attach>  
                    </td>
              </tr>  
			<tr>
				<td class="pformleft" align="right" valign="top">通知内容
				</td>
				<td align="left" class="pformrightline" colspan="3">
                 <FTB:FreeTextBox ID="freText" runat="server" Width="100%" Height="350" FontFacesMenuPath="../css/" ></FTB:FreeTextBox>
			   </td>
			</tr>
			<tr>
			     <td  width="15%" align="right" class="pformleft"><nobr>回执选项 
			     </nobr>			  </td>
			     <td  align="left" class="pformrightline">
			         <nobr>
                         <asp:CheckBox ID="chkOpinion" runat="server" Text="需要回执"  onclick ="doCheckOption()"/>
				    </nobr>		
				</td>
				 <td  width="15%" align="right" class="pformleft"><nobr>回执要求</nobr>			  </td>
			    <td  align="left" class="pformright">
			        <nobr>
				        <asp:TextBox ID="txtRcontent" runat="server" Width="98%" CssClass="input" Enabled="false"></asp:TextBox>
				    </nobr>	
				</td>
			</tr>
			<%--<tr>
			    <td class="pformleft" align="right">提醒方式
				</td>
			    <td  width="15%"  align="left" class="pformrightline" colspan="3"><nobr>
			                <asp:CheckBoxList ID="check" runat="server" 
                        RepeatDirection="Horizontal">
                                <asp:ListItem Value="1">在线消息</asp:ListItem>
                                <asp:ListItem Value="2">即时通知</asp:ListItem>
                                <asp:ListItem Value="3">手机短信</asp:ListItem>
                    </asp:CheckBoxList> 
			     </nobr>			  </td>
			</tr>--%>
			<tr class="pformstrip" height="20">
               <td colspan="4" align="center">
                    <input type="button" id="btnSave" value="保存" class="button" onclick="doSave('1','1')" />
                    &nbsp;
                    <input type="button" id="btnSaveCont" value="保存并返回" class="button" onclick="doSave('1','2')" />
                    &nbsp;
                    <input type="button" id="btnSaveBack" value="发布" class="button" onclick="doSave('0','2')" />
                    &nbsp;                       
                    <input type="button" id="Button1" value="提醒设置" class="button" onclick="doRemind()" />
                    &nbsp;  
                    <input type="button" id="btnBack" value="返回" class="button" onclick="DoBack()" />
                    &nbsp;
                </td>
            </tr>
       </table>
    </form>
</body>
</html>
